<template>
    <base-panel>
        <top-simple-search @searchFun="query" @addFun="showDialog"
        ></top-simple-search>
        <simple-table ref="myTable">
            <el-table-column align="left" prop="name" label="名称">
            </el-table-column>
            <el-table-column align="left" prop="value" label="key值">
            </el-table-column>
            <el-table-column align="left" prop="gmt_modified" label="更新时间" width="170"/>
            <el-table-column align="left" prop="gmt_created" label="创建时间" width="170"/>
            <el-table-column align="left" fixed="right" label="操作" width="100">
                <template slot-scope="{ row }">
                    <edit-button @click="editMenuButton(row,true)"></edit-button>
                    <delete-button @click="deleteMenuButton(row.id)"></delete-button>
                </template>
            </el-table-column>
        </simple-table>
        <edit-dialog :visible.sync="visible" v-if="visible" @reloadList="getMenuButtonList" :row="currRow"></edit-dialog>
    </base-panel>
</template>

<script>
    import buttons from "@/api/systemManagement/buttons/index";
    import EditDialog from "./editDialog";
    export default {
        name: "menuButton",
        components: {EditDialog},
        data() {
            return {
                visible: false,
                currRow: {},
                disabled:false
            };
        },
        created() {},
        watch: {},
        methods: {
            showDialog(){
                this.visible = true
                this.currRow = {}
            },
            query(queryData) {
                this.$refs["myTable"].searchList(queryData);
            },
            getMenuButtonList() {
                this.$refs["myTable"].searchList();
            },
            editMenuButton(row){
                this.visible = true
                this.currRow = row
            },
            deleteMenuButton(id) {
                this.$confirm("删除该条数据, 是否继续?", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning"
                }).then(() => {
                    buttons.deleteButtons(id).then(res => {
                      this.msgSuccess("删除成功!");
                      this.getMenuButtonList();
                  });
                });
            }
        }
    };
</script>
